package com.example.demo.controller;

import com.example.demo.domain.Department;
import com.example.demo.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/studentInfoSys")
public class DepartmentController {
@Autowired
DepartmentService departmentService;

    @PostMapping("/department")
    public List<Department> addDepartment(@RequestBody Department department){
    return departmentService.addDepartment(department);
    }
    @PostMapping("/departments")
    public List<Department> addDepartments(@RequestBody List<Department> departments){
        return departmentService.addDepartments(departments);
    }
    @GetMapping("/departments")
    public List<Department> getAll(){
        return departmentService.getAll();
    }
    @GetMapping("/departments/{no}")
    public Department getOneByNo(@PathVariable("no") String no){
        return departmentService.getOneByNo(no);
    }
}
